<?php
/**
 * Display single product reviews (comments)
 *
 * @author 		WooThemes
 * @package 	WooCommerce/Templates
 * @version     2.0.3
 */
global $woocommerce, $product;

if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly

?>
<?php if ( comments_open() ) : ?><div id="reviews">
    
    
    <?php

    
        echo '<div id=""><div id="review_form">';

	$comment_form = array(
		'title_reply' => $title_reply,
		'comment_notes_before' => '',
		'comment_notes_after' => '',
		'fields' => array(
			'author' => '<div class="form-group">
                        <label for="inputName" class="col-lg-3 col-sm-4 control-label hidden-sm">Họ tên</label>
                        <div class="col-lg-9 col-sm-8">
                            <input type="text" name="author" class="form-control input-small" id="author" placeholder="Họ tên">
                        </div>
                    </div>',
			'email'  => '<div class="form-group">
                        <label for="inputName" class="col-lg-3 col-sm-4 control-label hidden-sm">Email</label>
                        <div class="col-lg-9 col-sm-8">
                            <input type="text" name="email" class="form-control input-small" id="email" placeholder="Họ tên">
                        </div>
                    </div>',
                    'comment_field' => '<div class="form-group">
                        <label for="inputMessage" class="col-lg-3 col-sm-4 control-label hidden-sm">Nội dung</label>
                        <div class="col-lg-9 col-sm-8">
                            <textarea class="form-control input-small" name="comment" id="comment" placeholder="Nội dung" rows="6"></textarea>
                        </div>
                    </div>',
                    'submit' => '<div class="form-group">
                        <div class="col-lg-3 col-sm-4 control-label hidden-sm"></div>
                        <div class="col-lg-2 col-sm-3">
                            <button class="btn btn-custom">Gửi</button>
                        </div>
                    </div>'
		),
		'logged_in_as' => '',
		'comment_field' => ''
	);

	


	comment_form( apply_filters( 'woocommerce_product_review_comment_form_args', $comment_form ) );

	echo '</div></div>';
        
	echo '<div id="comments">';

	if ( get_option('woocommerce_enable_review_rating') == 'yes' ) {

		$count = $product->get_rating_count();

		if ( $count > 0 ) {

			$average = $product->get_average_rating();

			echo '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';

			echo '<div class="star-rating" title="'.sprintf(__( 'Rated %s out of 5', 'woocommerce' ), $average ).'"><span style="width:'.( ( $average / 5 ) * 100 ) . '%"><strong itemprop="ratingValue" class="rating">'.$average.'</strong> '.__( 'out of 5', 'woocommerce' ).'</span></div>';

			echo '<h2>'.sprintf( _n('%s review for %s', '%s reviews for %s', $count, 'woocommerce'), '<span itemprop="ratingCount" class="count">'.$count.'</span>', wptexturize($post->post_title) ).'</h2>';

			echo '</div>';

		} else {

			echo '<h2>'.__( 'Reviews', 'woocommerce' ).'</h2>';

		}

	} else {

		echo '<h2>'.__( 'Reviews', 'woocommerce' ).'</h2>';

	}

	$title_reply = '';

	if ( have_comments() ) :

		echo '<ol class="commentlist">';

		wp_list_comments( array( 'callback' => 'woocommerce_comments' ) );

		echo '</ol>';

		if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : ?>
			<div class="navigation">
				<div class="nav-previous"><?php previous_comments_link( __( '<span class="meta-nav">&larr;</span> Previous', 'woocommerce' ) ); ?></div>
				<div class="nav-next"><?php next_comments_link( __( 'Next <span class="meta-nav">&rarr;</span>', 'woocommerce' ) ); ?></div>
			</div>
		<?php endif;

		echo '<p class="add_review"><a href="#review_form" class="inline show_review_form button" title="' . __( 'Add Your Review', 'woocommerce' ) . '">' . __( 'Add Review', 'woocommerce' ) . '</a></p>';

		$title_reply = __( 'Add a review', 'woocommerce' );

	else :

		$title_reply = __( 'Be the first to review', 'woocommerce' ).' &ldquo;'.$post->post_title.'&rdquo;';

		echo '<p class="noreviews">'.__( 'There are no reviews yet, would you like to <a href="#review_form" class="inline show_review_form">submit yours</a>?', 'woocommerce' ).'</p>';

	endif;

	$commenter = wp_get_current_commenter();

	echo '</div>' ; 
        

?><div class="clear"></div></div>
<?php endif; ?>